package com.quark.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.quark.bo.Sekill;
import com.quark.dao.SekillDao;

@Service
public class SekillService {
    
	@Autowired
	private SekillDao sekillDao;
	
	public Sekill querySekillById(Integer id){
		return sekillDao.querySekillById(id);
	}
	
	public List<Sekill> queryAllSekill(int pageNum,int pageSize){
		Page<Sekill> page = PageHelper.startPage(pageNum, pageSize);
		sekillDao.queryAllSekill();
		//PageInfo<Sekill> p = new PageInfo<Sekill>(sekillDao.queryAllSekill());
		System.out.println(page.toString());
		return page.getResult();
	}
	
	@Transactional
	public int insertAndDeleteSekill(Integer id){
		Sekill sekill = new Sekill();
		sekill.setName("iphone6s");
		sekill.setDescription("苹果新一代商品");
		sekill.setNumber(100);
		int insertNum = sekillDao.insertSekill(sekill);
		sekillDao.deleteSekill(id);
		return insertNum;
	}
}
